treeview: Remove gtk_tree_view_get_bin_window()
authorBenjamin Otte <otte@redhat.com>
Sat, 7 Jan 2017 15:07:21 +0000 (16:07 +0100)
committerBenjamin Otte <otte@redhat.com>
Sat, 7 Jan 2017 23:48:12 +0000 (00:48 +0100)
We don't want to expose GdkWindows in the public API.

docs/reference/gtk/gtk4-sections.txt
gtk/a11y/gtktextcellaccessible.c
gtk/a11y/gtktreeviewaccessible.c
gtk/gtkrecentchooserdefault.c
gtk/gtktreeview.c
gtk/gtktreeview.h
tests/testtreeedit.c

index 220d5c31540493451614f191aee281d63ed54379..52ee4142f80870198a15b2371814d73437c1f0ef 100644 (file)
@@ -3922,7 +3922,6 @@ gtk_tree_view_get_cell_area
 gtk_tree_view_get_background_area
 gtk_tree_view_get_visible_rect
 gtk_tree_view_get_visible_range
-gtk_tree_view_get_bin_window
 gtk_tree_view_convert_bin_window_to_tree_coords
 gtk_tree_view_convert_bin_window_to_widget_coords
 gtk_tree_view_convert_tree_to_bin_window_coords
index 24fc72b2d0a399113ed32ed49c658603f286ed4c..a64df616bbc064223a8d49d3d841ab0d4e2d88ed 100644 (file)
@@ -486,14 +486,20 @@ get_origins (GtkWidget *widget,
 {
   GdkWindow *window;
 
-  if (GTK_IS_TREE_VIEW (widget))
-    window = gtk_tree_view_get_bin_window (GTK_TREE_VIEW (widget));
-  else
-    window = gtk_widget_get_window (widget);
-
+  window = gtk_widget_get_window (widget);
   gdk_window_get_origin (window, x_window, y_window);
   window = gdk_window_get_toplevel (gtk_widget_get_window (widget));
   gdk_window_get_origin (window, x_toplevel, y_toplevel);
+
+  if (GTK_IS_TREE_VIEW (widget))
+    {
+      gtk_tree_view_convert_widget_to_bin_window_coords (GTK_TREE_VIEW (widget),
+                                                         *x_window, *y_window,
+                                                         x_window, y_window);
+      gtk_tree_view_convert_widget_to_bin_window_coords (GTK_TREE_VIEW (widget),
+                                                         *x_toplevel, *y_toplevel,
+                                                         x_toplevel, y_toplevel);
+    }
 }
 
 static void
index a95054d7c73c2d5105a662d8a88a2c4ab658596c..65a68f3165d9c7b49d72e9ad97143692c94db157 100644 (file)
@@ -1081,7 +1081,6 @@ gtk_tree_view_accessible_get_cell_extents (GtkCellAccessibleParent *parent,
 {
   GtkWidget *widget;
   GtkTreeView *tree_view;
-  GdkWindow *bin_window;
   GdkRectangle cell_rect;
   gint w_x, w_y;
 
@@ -1091,19 +1090,20 @@ gtk_tree_view_accessible_get_cell_extents (GtkCellAccessibleParent *parent,
 
   tree_view = GTK_TREE_VIEW (widget);
   gtk_tree_view_accessible_get_cell_area (parent, cell, &cell_rect);
-  bin_window = gtk_tree_view_get_bin_window (tree_view);
-  gdk_window_get_origin (bin_window, &w_x, &w_y);
+  gtk_tree_view_convert_widget_to_bin_window_coords (tree_view,
+                                                     0, 0, 
+                                                     &w_x, &w_y);
 
-  if (coord_type == ATK_XY_WINDOW)
+  if (coord_type != ATK_XY_WINDOW)
     {
       GdkWindow *window;
       gint x_toplevel, y_toplevel;
 
-      window = gdk_window_get_toplevel (bin_window);
+      window = gdk_window_get_toplevel (gtk_widget_get_window (widget));
       gdk_window_get_origin (window, &x_toplevel, &y_toplevel);
 
-      w_x -= x_toplevel;
-      w_y -= y_toplevel;
+      w_x += x_toplevel;
+      w_y += y_toplevel;
     }
 
   *width = cell_rect.width;
index 1e1a3f6871dab8d1529ab9e2627a2619f465a2e1..f6c74dae295b72badacc4939671e25d4f06659c0 100644 (file)
@@ -1718,9 +1718,6 @@ recent_view_button_press_cb (GtkWidget      *widget,
       GtkTreePath *path;
       gboolean res;
 
-      if (event->window != gtk_tree_view_get_bin_window (GTK_TREE_VIEW (impl->priv->recent_view)))
-        return FALSE;
-
       res = gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (impl->priv->recent_view),
                                           event->x, event->y,
                                           &path,
index 19c60e56c3dda09416eba2abd69d34a7103838cb..206d3c048dc7c260f8ebf3f6c136a4b50403252b 100644 (file)
@@ -13013,25 +13013,6 @@ gtk_tree_view_set_cursor_on_cell (GtkTreeView       *tree_view,
     }
 }
 
-/**
- * gtk_tree_view_get_bin_window:
- * @tree_view: A #GtkTreeView
- *
- * Returns the window that @tree_view renders to.
- * This is used primarily to compare to `event->window`
- * to confirm that the event on @tree_view is on the right window.
- *
- * Returns: (nullable) (transfer none): A #GdkWindow, or %NULL when @tree_view
- * hasn’t been realized yet.
- **/
-GdkWindow *
-gtk_tree_view_get_bin_window (GtkTreeView *tree_view)
-{
-  g_return_val_if_fail (GTK_IS_TREE_VIEW (tree_view), NULL);
-
-  return tree_view->priv->bin_window;
-}
-
 /**
  * gtk_tree_view_get_path_at_pos:
  * @tree_view: A #GtkTreeView.
@@ -13046,11 +13027,10 @@ gtk_tree_view_get_bin_window (GtkTreeView *tree_view)
  * @cell_y: (out) (optional): A pointer where the Y coordinate
  *   relative to the cell can be placed, or %NULL
  *
- * Finds the path at the point (@x, @y), relative to bin_window coordinates
- * (please see gtk_tree_view_get_bin_window()).
- * That is, @x and @y are relative to an events coordinates. @x and @y must
- * come from an event on the @tree_view only where `event->window ==
- * gtk_tree_view_get_bin_window ()`. It is primarily for
+ * Finds the path at the point (@x, @y), relative to bin_window coordinates.
+ * That is, @x and @y are relative to an events coordinates. Widget-relative
+ * coordinates must be converted using
+ * gtk_tree_view_convert_widget_to_bin_window_coords(). It is primarily for
  * things like popup menus. If @path is non-%NULL, then it will be filled
  * with the #GtkTreePath at that point.  This path should be freed with
  * gtk_tree_path_free().  If @column is non-%NULL, then it will be filled
@@ -13491,8 +13471,7 @@ gtk_tree_view_convert_tree_to_widget_coords (GtkTreeView *tree_view,
  * @bx: (out): return location for bin_window X coordinate
  * @by: (out): return location for bin_window Y coordinate
  *
- * Converts widget coordinates to coordinates for the bin_window
- * (see gtk_tree_view_get_bin_window()).
+ * Converts widget coordinates to coordinates for the bin_window.
  *
  * Since: 2.12
  **/
@@ -13519,8 +13498,7 @@ gtk_tree_view_convert_widget_to_bin_window_coords (GtkTreeView *tree_view,
  * @wx: (out): return location for widget X coordinate
  * @wy: (out): return location for widget Y coordinate
  *
- * Converts bin_window coordinates (see gtk_tree_view_get_bin_window())
- * to widget relative coordinates.
+ * Converts bin_window coordinates to widget relative coordinates.
  *
  * Since: 2.12
  **/
@@ -13676,8 +13654,8 @@ gtk_tree_view_get_visible_range (GtkTreeView  *tree_view,
  * selection, having a custom context menu or starting rubber banding.
  *
  * The @x and @y coordinate that are provided must be relative to bin_window
- * coordinates.  That is, @x and @y must come from an event on @tree_view
- * where `event->window == gtk_tree_view_get_bin_window ()`.
+ * coordinates.  Widget-relative coordinates must be converted using
+ * gtk_tree_view_convert_widget_to_bin_window_coords().
  *
  * For converting widget coordinates (eg. the ones you get from
  * GtkWidget::query-tooltip), please see
index b1ac055b51a9d8ebd401d8d03279aec2662d0939..da4062b0f4559c9ac3460c146a6a855650fc1fe7 100644 (file)
@@ -345,8 +345,6 @@ void                   gtk_tree_view_get_cursor                    (GtkTreeView
 
 /* Layout information */
 GDK_AVAILABLE_IN_ALL
-GdkWindow             *gtk_tree_view_get_bin_window                (GtkTreeView               *tree_view);
-GDK_AVAILABLE_IN_ALL
 gboolean               gtk_tree_view_get_path_at_pos               (GtkTreeView               *tree_view,
                                                                    gint                       x,
                                                                    gint                       y,
index 676ec72c233462fd0726e2fa9f9a7ad6c5dccb22..994f0342c13606784af3339f676e342262d769a0 100644 (file)
@@ -137,9 +137,8 @@ static gboolean
 button_press_event (GtkWidget *widget, GdkEventButton *event, gpointer callback_data)
 {
        /* Deselect if people click outside any row. */
-       if (event->window == gtk_tree_view_get_bin_window (GTK_TREE_VIEW (widget))
-           && !gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (widget),
-                                              event->x, event->y, NULL, NULL, NULL, NULL)) {
+       if (!gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (widget),
+                                           event->x, event->y, NULL, NULL, NULL, NULL)) {
                gtk_tree_selection_unselect_all (gtk_tree_view_get_selection (GTK_TREE_VIEW (widget)));
        }